//
//  MYCloudDiskContentModel.swift
//  MYDoctor
//
//  Created by Denny on 2024/3/10.
//

import UIKit
import HandyJSON

class MYCloudDiskManager:NSObject {
    static let shared = MYCloudDiskManager()
    var shareModel = MYCloudDiskShareModel()
}

struct MYCloudDiskShareModel:HandyJSON {
    var link_invite = ""
    var link_open = ""
    var link_code = ""
}
class MYCloudDiskContentModel: HandyJSON {
    required init() {}
    var name = ""
    var pid = ""
    var is_sharing = ""
    var user = ""
    var updated_at = ""
    var created_at = ""
    var id = ""
    var f_id = -1
    var file_type = -1
    var type = 0//0：文件夹 1:图片2：视频3：文档
    var url = ""
    var selected = false
    var desc = ""
}

class MYCloudDiskValidityPeriodModel: HandyJSON {
    required init() {}
    var title = ""
    var subTitle = ""
    var selected = false
}

class MYCloudDiskAddFileListModel: HandyJSON {
    required init() {}
    var list = [MYCloudDiskContentModel]()
    var up_num = ""
}


class DataModel: HandyJSON {
    required init() {}
    var vid: String = ""
    var url: String = ""
    var fileName: String = ""
    var directory: String = ""
    var localPath: String = ""
    var state: CXDownloadState = .default
    var speed: Int64 = 0
    var totalFileSize: Int64 = 0
    var tmpFileSize: Int64 = 0
    var progress: Float = 0
}

extension CXDownloadModel {
    func toDataModel(with vid: String) -> DataModel {
        let model = DataModel()
        model.vid = vid
        model.url = url ?? ""
        model.fileName = fileName ?? ""
        model.directory = directory ?? ""
        model.localPath = localPath ?? ""
        model.state = state
        model.speed = speed
        model.totalFileSize = totalFileSize
        model.tmpFileSize = tmpFileSize
        model.progress = progress
        return model
    }
}
